﻿#include "ToolBarEvent.h"

#include "OperatorsInterface/GraphEventOperator.h"
#include "PostGraphAdaptor/PostGraphObjectBase.h"
#include "PostGraphAdaptor/PostGraphProperty.h"
#include "PostGraphAdaptor/PostGraphObjectManager.h"

#include "FITK_Interface/FITKInterfaceCFDPost/FITKAbstractCFDPostData.h"
#include "FITK_Interface/FITKInterfaceCFDPost/FITKCFDPost3DManager.h"
#include "FITK_Interface/FITKInterfaceCFDPost/FITKCFDPostData.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Kernel/FITKCore/FITKOperatorRepo.h"

namespace GUI {
    ToolBarEvent::ToolBarEvent(SARibbonPannel* pannel) :
        ToolBarBase(pannel) {
        _extremumAction = createAction(tr("Extremum"),"actionExtremum", ":/icons/Extremum.png", "Extremum");
        this->addAction(_extremumAction);

       /* QAction* action = createAction(tr("Light"),"actionLight", "", "Light");
        action->setCheckable(true);
        this->addAction(action);*/

        QAction* calculatorAction = createAction(tr("Calculator"),"actionCalculator", ":/icons/calculator.png", "Calculator");
        calculatorAction->setCheckable(true);
        this->addAction(calculatorAction);

        QAction* integralAction = createAction(tr("Integral"), "actionIntegral", ":/icons/integral.png", "Integral");
        integralAction->setCheckable(true);
        this->addAction(integralAction);
//        this->addSeparator();
        updateCurrentGraphObj(-1);
    }

    ToolBarEvent::~ToolBarEvent() {

    }

    void ToolBarEvent::updateCurrentGraphObj(int objID) {
        _currentDataID = objID;
        _extremumAction->setEnabled(false);
        Interface::FITKAbstractCFDPostData* currentData = _postDataManager->getDataByID(_currentDataID);
        if (currentData == nullptr) {
            return;
        }

        _extremumAction->setEnabled(true);
    }
}
